// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import realThing from "../BASE/realThing";


import DES from "../Ditu/des/DES";
import DESManager from "../Ditu/des/DESManager";
import S00 from "../Scharacter/S00";
import S01 from "../Scharacter/S01";
import S02 from "../Scharacter/S02";
import S03 from "../Scharacter/S03";
import S04 from "../Scharacter/S04";
import S06 from "../Scharacter/S06";
import S07 from "../Scharacter/S07";
import S09 from "../Scharacter/S09";
import S14 from "../Scharacter/S14";
import S17 from "../Scharacter/S17";




import turn from "../game/time/turn";


import KHD from "../Message/KHD";

import { Message } from "../Message/Message";
import MessageCenter from "../Message/MessageCenter";
import GeZiManager from "./GeZiManager";
import ManagerBase from "./ManagerBase";
import { SHMessage } from "../Message/SHMessage";
import Character from "../BASE/Character";
import player from "../game/player";
import state from "../game/time/state";
import Obstacles from "../BASE/ Obstacles";
import qizi from "../../node/Dixing/qizi";
import Qin from "../BASE/qin";
import { gif } from "../BASE/spineANDgif/gif";
import shopM from "../UIS/shop/ShopM";
import S05 from "../Scharacter/S05";
import fireball from "../Ditu/des/fireball";
import SXX from "../Scharacter/SXX";
import TNanager from "./TNanager";
import ZManager from "./ZManager";
import grass from "../../node/Dixing/grass";
import box from "../../node/Dixing/box";
import NWshopM from "../UIS/shop/NWshopM";
import grassQ from "../../node/Dixing/grassQ";
import JNUM from "../UIS/else/JNUmanager";
import S10 from "../Scharacter/S10";
import Wpig from "../dNM/Wpig";
import { parse } from "path";
import NG from "../../node/Dixing/NG";
import Wsheep from "../dNM/Wsheep";
import GeZi from "../Ditu/Gezi/GeZi";
import TG from "../../node/Dixing/TG";
import FH from "../../node/Dixing/FHT";
import FHT from "../../node/Dixing/FHT";
import KHD2 from "../Message/KHD2";
import YP from "../../sound/music";









const {ccclass, property} = cc._decorator;

@ccclass
export default class AnimalManager extends ManagerBase {
 ac:cc.Node[]=[]
P1SN:number=0;
 P2SN:number=0;   
 P3SN:number=0;
 P4SN:number=0;
 P5SN:number=0;
 P6SN:number=0;
juese:string[]=["SXX","S04","S01","S05","S08","S02","S00"];
@property(cc.Prefab)
 s00:cc.Prefab=null;
 @property(cc.Prefab)
 s01:cc.Prefab=null;
 @property(cc.Prefab)
s02:cc.Prefab=null;;
 @property(cc.Prefab)
 s03:cc.Prefab=null;;
 @property(cc.Prefab)
 s04:cc.Prefab=null;;
 @property(cc.Prefab)
 s05:cc.Prefab=null;;
 @property(cc.Prefab)
 s06:cc.Prefab=null;;
 @property(cc.Prefab)
 s07:cc.Prefab=null;;
 @property(cc.Prefab)
 s08:cc.Prefab=null;
 @property(cc.Prefab)
 s09:cc.Prefab=null;
 @property(cc.Prefab)
 s10:cc.Prefab=null;;
 @property(cc.Prefab)
 s11:cc.Prefab=null;
 @property(cc.Prefab)
s12:cc.Prefab=null;;
 @property(cc.Prefab)
 s13:cc.Prefab=null;;
 @property(cc.Prefab)
 s14:cc.Prefab=null;;
 @property(cc.Prefab)
 s15:cc.Prefab=null;;
 @property(cc.Prefab)
 s16:cc.Prefab=null;;
 @property(cc.Prefab)
 s17:cc.Prefab=null;;
 @property(cc.Prefab)
 s18:cc.Prefab=null;
 @property(cc.Prefab)
 s19:cc.Prefab=null;
 @property(cc.Prefab)
 s20:cc.Prefab=null;;
P1P:Character=null;
messageType: String="AM"

 YuanGong:realThing[]=[];
static FF:number[]=[]


@property(cc.Prefab)
 FDUIs:cc.Prefab=null;;

 @property(cc.Prefab)
 FH:cc.Prefab=null;;
@property(cc.Prefab)
tree:cc.Prefab=null;;
@property(cc.Prefab)
rock:cc.Prefab=null;;
@property(cc.Prefab)
DL:cc.Prefab=null;;
@property(cc.Prefab)
banana:cc.Prefab=null;
@property(cc.Prefab)
fireball:cc.Prefab=null;
@property(cc.Prefab)
GE:cc.Prefab=null;
@property(cc.Prefab)
qin:cc.Prefab=null;
@property(cc.Prefab)
qizi:cc.Prefab=null;
@property(cc.Prefab)
water:cc.Prefab=null;
@property(cc.Prefab)
grass:cc.Prefab=null;
@property(cc.Prefab)
grassQ:cc.Prefab=null;
@property(cc.Prefab)
box:cc.Prefab=null;
@property(cc.Prefab)
sheep:cc.Prefab=null;
@property(cc.Prefab)
cow:cc.Prefab=null;
@property(cc.Prefab)
wa:cc.Prefab=null;
@property(cc.Prefab)
pig:cc.Prefab=null;
@property(cc.Prefab)
ng:cc.Prefab=null;
@property(cc.Prefab)
tg:cc.Prefab=null;
@property(cc.SpriteAtlas)
TouX:cc.SpriteAtlas=null;
makeDL(ZB:number){
if (!GeZiManager.aos.includes(ZB)) {
    let DL=cc.instantiate(this.DL)

    //GeZiManager.DL.push([ZB,3])
    GeZiManager.AllObstacles.push(DL.getComponent(DES))
    GeZiManager.aos.push(ZB)
    DL.setParent(this.node)
    DL.getComponent(realThing).ghost=true;
    DL.getComponent(realThing).ZB=ZB;
    DL.getComponent(realThing).setXY(0.8);
    DL.getComponent(realThing).moveto(0,ZB)
    if (GeZiManager.grass.includes(ZB)) {
       if (KHD2.PT.includes(GeZiManager.PCP.Pturn)) {
        DL.opacity=155;
       } else{DL.active =false}
    }
}

 
}

makeNG(ZB:number){
    if (!GeZiManager.aos.includes(ZB)) {
        let NG1=cc.instantiate(this.ng)
    
        //GeZiManager.DL.push([ZB,3])
        GeZiManager.AllObstacles.push(NG1.getComponent(DES))
        GeZiManager.aos.push(ZB)
       NG1.setParent(this.node)
        NG1.getComponent(realThing).ghost=true;
        NG1.getComponent(realThing).ZB=ZB;
        NG1.getComponent(realThing).setXY(0.8);
        NG1.getComponent(realThing).moveto(0,ZB)
    // NG1.getComponent(NG).DJ=NWshopM.NGS
for(let a of GeZiManager.AllObstacles){
        if(GeZiManager.grass.includes(a.ZB)&&this.getNIG(ZB).includes(a.ZB)){

a.node.opacity=155


        }

    
     
    }
    NG1.opacity=255 

    }

}

    

makeTree(ZB:number){

let tree=cc.instantiate(this.tree)
tree.setParent(this.node)
tree.getComponent(realThing).ZB=ZB;
tree.getComponent(realThing).WD=true;
tree.getComponent(realThing).M="扎了根";

tree.getComponent(realThing).moveto(0,ZB)
this.node.getComponent(AnimalManager).YuanGong.push(tree.getComponent(realThing))
tree.getComponent(realThing).HP=2;
GeZiManager.trees.push(ZB)

}
makeRock(ZB:number){


let rock=cc.instantiate(this.rock)
rock.setParent(this.node)
rock.getComponent(realThing).ZB=ZB;
rock.getComponent(realThing).WD=true;
rock.getComponent(realThing).M="沉甸甸";
GeZiManager.rock.push(ZB);
rock.getComponent(realThing).tt="rock"
rock.getComponent(realThing).moveto(0,ZB)
this.node.getComponent(AnimalManager).YuanGong.push(rock.getComponent(realThing))
rock.getComponent(realThing).HP=5;
GeZiManager.trees.push(ZB)
}

makeBox(ZB:number,type:number){


    let box1=cc.instantiate(this.box)
   box1.setParent(this.node)
   box1.getComponent(box).ZB=ZB;
GeZiManager.boxs.push(ZB)
    box1.getComponent(realThing).WD=true;
    box1.getComponent(realThing).M="正常";
   // GeZiManager.rock.push(ZB);

   box1.getComponent(box).moveto(0,ZB)
    this.node.getComponent(AnimalManager).YuanGong.push(box1.getComponent(realThing))
    box1.getComponent(box).sk(type);
    box1.getComponent(box).move(5,1)
   

    }
    makePig(ZB:number,type:number){
//let j=parseInt(type);

        let pig1=cc.instantiate(this.pig)
        pig1.setParent(this.node)
        pig1.getComponent(Wpig).ZB=ZB;
   // GeZiManager.boxs.push(ZB)

   pig1.getComponent(Wpig).M="正常";
       // GeZiManager.rock.push(ZB);
    
       pig1.getComponent(Wpig).moveto(0,ZB)
        this.node.getComponent(AnimalManager).YuanGong.push(pig1.getComponent(Wpig))
        pig1.getComponent(Wpig).T=4;
        pig1.getComponent(Wpig).faceTo=type
        pig1.getComponent(Wpig).move(5,1)
       
    
        }

        makeSheep(ZB:number,type:number){
            //let j=parseInt(type);
            
                    let sheep1=cc.instantiate(this.sheep)
                    sheep1.setParent(this.node)
                    sheep1.getComponent(Wsheep).ZB=ZB;
               // GeZiManager.boxs.push(ZB)
                    sheep1.getComponent(Wsheep).M="正常";
                   // GeZiManager.rock.push(ZB);
                    sheep1.getComponent(Wsheep).moveto(0,ZB)
                    this.node.getComponent(AnimalManager).YuanGong.push(sheep1.getComponent(Wsheep))
                    sheep1.getComponent(Wsheep).T=type;
                    sheep1.getComponent(Wsheep).faceTo=type
                    sheep1.getComponent(Wsheep).move(5,1)
                   
                
                    }
makeFireball(ZB:number,sh:number){

    let fireball1=cc.instantiate(this.fireball)
    fireball1.setParent(this.node);
   
    
   fireball1.getComponent(realThing).ghost=true;
   fireball1.getComponent(realThing).ZB=ZB;
    fireball1.getComponent(realThing).setXY(0.8);
    fireball1.getComponent(realThing).moveto(0,ZB)
    fireball1.getComponent(fireball).SH=sh;
  
GeZiManager.clean();


}

makeFH(ZB:number,sh:number){

    let fireball1=cc.instantiate(this.FH)
    fireball1.setParent(this.node);
   
    
   fireball1.getComponent(realThing).ghost=false;
   fireball1.getComponent(realThing).ZB=ZB;
    fireball1.getComponent(realThing).setXY(0.8);
    fireball1.getComponent(realThing).moveto(0,ZB)
    fireball1.getComponent(FHT).turn=sh;
    fireball1.getComponent(FHT).FT=turn.turn;
GeZiManager.clean();


}

makeTG(ZB:number,type:string){

    let q=cc.instantiate(this.tg)


    q.getComponent(realThing).tt="TG";
    q.setParent(this.node)
   q.getComponent(realThing).ghost=true;
    q.getComponent(realThing).ZB=ZB;
    q.getComponent(TG).N=type;
    q.getComponent(TG).k()
    q.getComponent(realThing).setXY(0.8);
    q.getComponent(realThing).moveto(0,ZB)
   // q.getComponent(gif).changeF(type,1);
    
}

makeQin(ZB:number,type:number){

    let q=cc.instantiate(this.qin)


    q.getComponent(realThing).tt="qin";
    q.setParent(this.node)
   q.getComponent(realThing).ghost=true;
    q.getComponent(realThing).ZB=ZB;
    GeZiManager.qin.push(q.getComponent(Qin))  
    GeZiManager.qins.push(q.getComponent(realThing).ZB)  
    q.getComponent(Qin).type=type;
    q.getComponent(realThing).M="正常";;
    q.getComponent(realThing).setXY(0.8);
    q.getComponent(realThing).moveto(0,ZB)
   // q.getComponent(gif).changeF(type,1);
    
}


makeGE(ZB:number,Type:number){


    let GE=cc.instantiate(this.GE);
    GE.setParent(this.node);
    
    GE.getComponent(realThing).ZB=ZB;
    GE.getComponent(realThing).moveto(0,ZB)
    GE.getComponent(realThing).setXY(0.8);
   GE.getComponent(realThing).ghost=true;
   
   
    
   GE.getComponent(realThing).ooo=Type;


}
makeBanan(ZB:number){
    let banana=cc.instantiate(this.banana) 
    banana.setParent(this.node)
    banana.getComponent(realThing).ghost=true;
    banana.getComponent(realThing).ZB=ZB;
    banana.getComponent(realThing).setXY(0.8);
    banana.getComponent(realThing).moveto(0,ZB)
    GeZiManager.AllObstacles.push(banana.getComponent(DES))
    GeZiManager.aos.push(ZB)
    if (GeZiManager.grass.includes(ZB)) {
        if (KHD2.PT.includes(GeZiManager.PCP.Pturn)) {
         banana.opacity=155;
        } else{banana.active =false}
     }
     }
    
    makeFlag(ZB:number,c:string){
        let qizi1=cc.instantiate(this.qizi)

        
        qizi1.setParent(this.node)
        qizi1.getComponent(realThing).ghost=true;
        qizi1.getComponent(realThing).ZB=ZB;
        qizi1.getComponent(realThing).setXY(0.8);
        qizi1.getComponent(realThing).moveto(0,ZB)
       if(c=="S02") {
        qizi1.getComponent(qizi).color="S02"
        this.node.getComponent(JNUM).JNF("S海盗旗",GeZiManager.PCP.ZB)  
       }else {
        qizi1.getComponent(qizi).color=c
       }

        console.log(   qizi1.getComponent(qizi).color)
        qizi1.getComponent(qizi).FZ();
        GeZiManager.AllObstacles.push(qizi1.getComponent(DES))
        GeZiManager.aos.push(ZB)
        this.node.getComponent(AnimalManager).YuanGong.push(qizi1.getComponent(realThing))
        }

        makeGrass(ZB:number,c:number){
            let G=cc.instantiate(this.grass)
    let GTT=cc.instantiate(this.grassQ)
            
           G.setParent(this.node)
           G.getComponent(realThing).ghost=true;
           G.getComponent(realThing).ZB=ZB;
           G.getComponent(realThing).setXY(0);
           G.getComponent(grass).FZ();
           G.getComponent(realThing).moveto(0,ZB)
           G.getComponent(grass).FW=[ZB]
 //G.rotation-=(G.getComponent(realThing).x-4)*2


            GTT.setParent(this.node)
            GTT.getComponent(realThing).ghost=true;
            GTT.getComponent(realThing).ZB=ZB;
           GTT.getComponent(realThing).setXY(0);
            GTT.getComponent(realThing).moveto(0,ZB)
            GTT.opacity=0
    
          //  GTT.rotation-=(G.getComponent(realThing).x-4)*2
           // G.getComponent(qizi).FZ();
          GeZiManager.grass.push(ZB)
          GeZiManager.GR.push(G.getComponent(grass))
          GeZiManager.AllObstacles.push(G.getComponent(DES))
          G.getComponent(grass).grassQ=GTT.getComponent(grassQ)
            this.node.getComponent(AnimalManager).YuanGong.push(G.getComponent(realThing))
            }

            makeWaterPool(ZB:number,c:number){
                let wat=cc.instantiate(this.water)
        
                
                wat.setParent(this.node)
                wat.getComponent(realThing).ghost=true;
                wat.getComponent(realThing).ZB=ZB;
                wat.getComponent(DES).FW=[ZB]
                wat.getComponent(realThing).setXY(0.8);
                wat.getComponent(realThing).moveto(0,ZB)
             GeZiManager.waterPool.push(ZB)
                GeZiManager.AllObstacles.push(wat.getComponent(DES))
                this.node.getComponent(AnimalManager).YuanGong.push(wat.getComponent(realThing))
                }




start(): void {
this.addck();
   GeZiManager.PCP=GeZiManager.P1;
 if (KHD2.socket) {
    let a=KHD2.PT.length
   if (a>3) {
    a=3
   }
   
  const data = {
   id:6,
    value:a
  
  };




KHD2.socket.send(JSON.stringify(data))
 }  
console.log(MessageCenter.Text)

cc.find("Canvas").getComponent(YP).stopAllAudio();
cc.find("Canvas").getComponent(YP).PlayAudioclip("byp",true,3)
cc.find("Canvas").getComponent(YP).PlayAudioclip("nyp",true,1)






}








static getc(nu:number){


    switch (nu) {
      case -1:break;
      
       case 1:return GeZiManager.P1
          
          break;
          case 2:return GeZiManager.P2
          
          break;
          case 3:return GeZiManager.P3
          
          break;
          case 4:return GeZiManager.P4
          
          break;
          case 5:return GeZiManager.P5
          
          break;
          case 6:return GeZiManager.P6
          
          break;
    
       default:
          break;
    }
    } 
  









onLoad(): void {
  
  
    MessageCenter.addReceive(this);

    cc.resources.loadDir("resources", (err, assets) => {
        if (err) {
            console.error(err);
            return;
        }
        // assets 参数是一个包含所有加载资源的数组
        console.log(assets); // 这里可以处理加载的资源
    });
   
   
   
   
   
     
     
       
      
       
     
      GeZiManager. blueP=[ GeZiManager.P1,GeZiManager.P3,GeZiManager.P5];
      for(let m of GeZiManager.p6F){console.log(GeZiManager.p6F[0].P6F());m.P6F();}       
   GeZiManager.redP=[ GeZiManager.P2,GeZiManager.P4,GeZiManager.P6];
    /*   let landnei:number[]=[19,20,21,22,27,28,29,30,35,36,37,38,43,44,45,46];
       let landwai:number[]=[10,11,12,13,14,15,18,23,26,31,34,39,42,47,50,51,52,53,54,55];
       let num1:number;
       let num2:number;
       let num3:number;
       function getRandomInt(min: number, max: number): number {
           min = Math.ceil(min);
           max = Math.floor(max);
           return Math.floor(Math.random() * (max - min + 1)) + min;
         }
       //第一个障碍物,num1是位置
       let t1=getRandomInt(1,10);
       if(t1>=1&&t1<=3)
       {
           let t2=getRandomInt(0,19);
           num1=landwai[t2];
       }
       else
       {
           let t2=getRandomInt(0,15);
           num1=landnei[t2];
       }
       //第二个,num2是位置
       let t3=getRandomInt(1,10);
       if(t3>=1&&t3<=3)
       {
           let t4=getRandomInt(0,19);
           let temp=landwai[t4];
           while(temp==num1+1||temp==num1-1||temp==num1+8||temp==num1-8||temp==num1)
           {
               t4=getRandomInt(0,19);
               temp=landwai[t4];
           }
           num2=temp;
       }
       else
       {
           let t4=getRandomInt(0,15);
           let temp=landnei[t4];
           while(temp==num1+1||temp==num1-1||temp==num1+8||temp==num1-8||temp==num1)
           {
               t4=getRandomInt(0,15);
               temp=landnei[t4];
           }
           num2=temp;
       }
       //第三个,num3是位置
       let t5=getRandomInt(1,10);
       if(t5>=1&&t5<=3)
       {
           let t6=getRandomInt(0,19);
           let temp2=landwai[t6];
           while(temp2==num1+1||temp2==num1-1||temp2==num1+8||temp2==num1-8||temp2==num2+1||temp2==num2-1||temp2==num2+8||temp2==num2-8||temp2==num2||temp2==num1)
           {
               t6=getRandomInt(0,19);
               temp2=landwai[t6];
           }
           num3=temp2;
       }
       else
       {
           let t6=getRandomInt(0,15);
           let temp2=landnei[t6];
           while(temp2==num1+1||temp2==num1-1||temp2==num1+8||temp2==num1-8||temp2==num2+1||temp2==num2-1||temp2==num2+8||temp2==num2-8||temp2==num2||temp2==num1)
           {
               t6=getRandomInt(0,15);
               temp2=landnei[t6];
           }
           num3=temp2;
       }
    //  AnimalManager.FF=[num1,num2,num3]
   */
      
  console.log(MessageCenter.Text)

  let Sb=[]
  let s1,s2,s3
  s1=this.addZ([2,3,4],[2,3],Sb)
  Sb.push(s1)
  s2=this.addZ([5,6,7],[2,3],Sb)

  Sb.push(s2)
  s3=this.addZ([0],[2],Sb)


    GeZiManager.BanMove.push(s1)
GeZiManager.BanMove.push(s2)
GeZiManager.BanMove.push(s3)
  

  AnimalManager.FF=[s1,s2,s3]







}


//GeZiManager.blueBan();
FTP(i:number){
    let a,k
    switch (i) {
        case 1:k=GeZiManager.P1
            
            break;
            case 2:k=GeZiManager.P2
            
            break;
            case 3:k=GeZiManager.P3
            
            break;
            case 4:k=GeZiManager.P4
            
            break;
            case 5:k=GeZiManager.P5
            
            break;
            case 6:k=GeZiManager.P6
            
            break;
        default:k=GeZiManager.P1
            break;
    }
 /* if ([1,3,5].includes(i)) {
  k=7 
  }else{k=8}
    switch (this.juese[k]) {
        case "S00":a=cc.instantiate(this.s00);
            
            break;
            case "S01":a=cc.instantiate(this.s01);
            
            break;
            case "S02":a=cc.instantiate(this.s02);
            
            break;
            case "S03":a=cc.instantiate(this.s03);
            
            break;
            case "S04":a=cc.instantiate(this.s04);
            
            break;
            case "S05":a=cc.instantiate(this.s05);
            
            break;
            case "S06":a=cc.instantiate(this.s06);
            
            break;
            case "S07":a=cc.instantiate(this.s07);
            
            break;
            case "S08":a=cc.instantiate(this.s08);
            
            break;
            case "S09":a=cc.instantiate(this.s09);
            
            break;
            case "S10":a=cc.instantiate(this.s10);
            
            break;
        default:a=cc.instantiate(this.s02);
            break;
    }
    a.getComponent(Character).Pturn=i;
  a.setParent(this.node);
  this.addReceive(a.getComponent(Character))

let j=cc.find("Canvas/UIManager/sideUIS")

switch (i) {
    case 1:GeZiManager.P1=a.getComponent(Character);j.children[i-1].children[3].children[0].getComponent(cc.Sprite).spriteFrame=this.TouX.getSpriteFrame(this.juese[i])
        
        break;
        case 2:GeZiManager.P2=a.getComponent(Character);j.children[i-1].children[3].children[0].getComponent(cc.Sprite).spriteFrame=this.TouX.getSpriteFrame(this.juese[i])
        
        break;
        case 3:GeZiManager.P3=a.getComponent(Character);j.children[i-1].children[3].children[0].getComponent(cc.Sprite).spriteFrame=this.TouX.getSpriteFrame(this.juese[i])
        
        break;
        case 4:GeZiManager.P4=a.getComponent(Character);j.children[i-1].children[3].children[0].getComponent(cc.Sprite).spriteFrame=this.TouX.getSpriteFrame(this.juese[i])
        
        
        break;
        case 5:GeZiManager.P5=a.getComponent(Character);j.children[i-1].children[3].children[0].getComponent(cc.Sprite).spriteFrame=this.TouX.getSpriteFrame(this.juese[i])
        
        
        break;
        case 6:GeZiManager.P6=a.getComponent(Character);j.children[i-1].children[3].children[0].getComponent(cc.Sprite).spriteFrame=this.TouX.getSpriteFrame(this.juese[i])
        
        
        break;

    default:
        break;
}
  
*/
state.ST=0.5
MessageCenter.MakeMessage("UIManager","change",-1);
GeZiManager.Tcharacter=a.getComponent(Character)
GeZiManager.GeZi=GeZiManager.PCP.ZB

for(let manager of GeZiManager.YuanGong){
let a=new Message("",[65],-1)
    manager.ReceiveMessage(a) ;   
}
MessageCenter.MakeMessage("AM",turn.turn,"getZB")

for(let manager of GeZiManager.YuanGong){
manager.getFar(5+GeZiManager.JL);}


}

addck(){
let c=[null,GeZiManager.P1,GeZiManager.P2,GeZiManager.P3,GeZiManager.P4,GeZiManager.P5,GeZiManager.P6]
for (let index =1; index <=6; index++) {
    let a
    switch (this.juese[index]) {
        case "S00":a=cc.instantiate(this.s00);
            
            break;
            case "S01":a=cc.instantiate(this.s01);
            
            break;
            case "S02":a=cc.instantiate(this.s02);
            
            break;
            case "S03":a=cc.instantiate(this.s03);
            
            break;
            case "S04":a=cc.instantiate(this.s04);
            
            break;
            case "S05":a=cc.instantiate(this.s05);
            
            break;
            case "S06":a=cc.instantiate(this.s06);
            
            break;
            case "S07":a=cc.instantiate(this.s07);
            
            break;
            case "S08":a=cc.instantiate(this.s08);
            
            break;
            case "S09":a=cc.instantiate(this.s09);
            
            break;
            case "S10":a=cc.instantiate(this.s10);
            
            break;

            case "S11":a=cc.instantiate(this.s11);
            
            break;
            case "S12":a=cc.instantiate(this.s12);
            
            break;
            case "S13":a=cc.instantiate(this.s13);
            
            break;
            case "S14":a=cc.instantiate(this.s14);
            
            break;
            case "S15":a=cc.instantiate(this.s15);
            
            break;
            case "S16":a=cc.instantiate(this.s16);
            
            break;
            case "S17":a=cc.instantiate(this.s07);
            
            break;
        default:a=cc.instantiate(this.s02);
            break;
    }
    a.getComponent(Character).Pturn=index;
  a.setParent(this.node);
  this.addReceive(a.getComponent(Character))
if(index==1){
    GeZiManager.PCP=a.getComponent(Character)
}
let j=cc.find("Canvas/UIManager/sideUIS")

switch (index) {
    case 1:GeZiManager.P1=a.getComponent(Character);j.children[index-1].children[3].children[0].getComponent(cc.Sprite).spriteFrame=this.TouX.getSpriteFrame(this.juese[index])
        
        break;
        case 2:GeZiManager.P2=a.getComponent(Character);j.children[index-1].children[3].children[0].getComponent(cc.Sprite).spriteFrame=this.TouX.getSpriteFrame(this.juese[index])
        
        break;
        case 3:GeZiManager.P3=a.getComponent(Character);j.children[index-1].children[3].children[0].getComponent(cc.Sprite).spriteFrame=this.TouX.getSpriteFrame(this.juese[index])
        
        break;
        case 4:GeZiManager.P4=a.getComponent(Character);j.children[index-1].children[3].children[0].getComponent(cc.Sprite).spriteFrame=this.TouX.getSpriteFrame(this.juese[index])
        
        
        break;
        case 5:GeZiManager.P5=a.getComponent(Character);j.children[index-1].children[3].children[0].getComponent(cc.Sprite).spriteFrame=this.TouX.getSpriteFrame(this.juese[index])
        
        
        break;
        case 6:GeZiManager.P6=a.getComponent(Character);j.children[index-1].children[3].children[0].getComponent(cc.Sprite).spriteFrame=this.TouX.getSpriteFrame(this.juese[index])
        
        
        break;

    default:
        break;
}
}





}



  ok(){

console.log("abc")

     MessageCenter.MakeGMessage("AM",[AnimalManager.FF[0]],1,1,"FTP");
     
        //   cc.view.enableAutoFullScreen(true); // 启用自动全屏
        
        //cc.game.frame.requestFullscreen();
        
        setTimeout(() => {
            MessageCenter.MakeGMessage("AM",[AnimalManager.FF[1]],1,1,"FTP");
        },200);
        
        setTimeout(() => {
            MessageCenter.MakeGMessage("AM",[AnimalManager.FF[2]],2,2,"FTP");
        }, 400);
        
        
        GeZiManager.blueBan();
            
            setTimeout(() => {
                MessageCenter.MakeGMessage("TN",TNanager.makePool(),0,0,"pool") 
            }, 600);
            setTimeout(() => {
          cc.find("Canvas/DituManager/New Node/AnimalManager").getComponent(ZManager).Cx(),800})
  }




static TP(PT:number,ZB:number){
   
AnimalManager.getc(PT).TP(ZB);
       
}
 


ReceiveMessage(message: Message){

        if(message instanceof SHMessage&& message.Type=="JN"){
            GeZiManager.PCP.node.getComponent(SXX).QDS(message.Content)
        console.log(this.name)
        }
     if (message instanceof SHMessage&& message.SHtype=="CX") {
        this.ok()
     }
    if(message.Type==this.messageType){

if(message instanceof SHMessage&& message.SHtype=="FTP"){

switch (message.Content) {
    case 1:this.makeTree(message.Command[0]);
        
        break;
        case 2:this.makeRock(message.Command[0]);if(state.ST==0&&KHD2.PT.includes(1)){GeZiManager.blueBan()}
        
        break;
        case 3:this.makeDL(message.Command[0]);shopM.A6n[1]-=1;if(this.PPC()){GeZiManager.TNC[5]=2};MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],shopM.A6n[0]+GeZiManager.free,GeZiManager.PCP.Pturn,"Qi-");GeZiManager.PCP.Bu.push(5);GeZiManager.PCP.DLN-=1;
        MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],GeZiManager.PCP.TNJJ[5]+GeZiManager.TNC[5],GeZiManager.PCP.Pturn,"TN-")
        break;
        case 3.5:this.makeNG(message.Command[0]);shopM.A6n[1]-=1;if(this.PPC()){GeZiManager.TNC[5]=2};MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],NWshopM.NGS,GeZiManager.PCP.Pturn,"Qi-");GeZiManager.PCP.Bu.push(5);GeZiManager.PCP.DLN-=1;
        MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],GeZiManager.PCP.TNJJ[5]+GeZiManager.TNC[5],GeZiManager.PCP.Pturn,"TN-")
        NWshopM.NGS++
        break;

        case 4:this.makeFireball(message.Command[0],message.Command[1]);
        
        break;
        case 5:this.makeGE
        
        break;
        case 6://this.makeQin(message.Command[0]);
        
        break;
        case 7:this.makeBanan(message.Command[0])
        
        break;
        case 8:this.makeFlag(message.Command[0],GeZiManager.PCP.color);
        shopM.A7n[GeZiManager.PCP.Pturn%2+1]-=1;if(this.PPC()){GeZiManager.TNC[5]=2};MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],shopM.A7n[0]+GeZiManager.free,GeZiManager.PCP.Pturn,"Qi-");GeZiManager.PCP.Bu.push(5);
        MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],GeZiManager.PCP.TNJJ[5]+GeZiManager.TNC[5],GeZiManager.PCP.Pturn,"TN-")
        break;
        case 8.1:this.makeFlag(message.Command[0],GeZiManager.PCP.color);
  
    MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],GeZiManager.PCP.getComponent(S10).qz+GeZiManager.free,GeZiManager.PCP.Pturn,"Qi-");
    MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],GeZiManager.PCP.TNJJ[5]+GeZiManager.TNC[5],GeZiManager.PCP.Pturn,"TN-")

    if (GeZiManager.PCP.getComponent(S10).BL[0]==0) {
        GeZiManager.PCP.getComponent(S10).qz++
    }    
   

        break;
        case 8.5:this.makeFlag(message.Command[0],"S02");
       if(this.PPC()){GeZiManager.TNC[5]=2};MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],1+GeZiManager.PCP.node.getComponent(S02).qz+GeZiManager.free,GeZiManager.PCP.Pturn,"Qi-");GeZiManager.PCP.Bu.push(5);
        MessageCenter.MakeSHMessage("AM",[GeZiManager.PCP.ZB],GeZiManager.PCP.TNJJ[5]+GeZiManager.TNC[5],GeZiManager.PCP.Pturn,"TN-")
        GeZiManager.PCP.node.getComponent(S02).qz++
        break;

        case 8.2:this.makeFlag(message.Command[0],"null");
    
         break;

        case 9:this.makeTG(message.Command[0],message.Command[1])
        
        break;
        case 10:this.makeQin(message.Command[0],message.Command[1])
        
        break;
        case 11:this.makeGrass(message.Command[0],message.Command[1])
        
        break;
        case 12:this.makeWaterPool(message.Command[0],message.Command[1])
        
        break;
        case 13:this.makeBox(message.Command[0],message.Command[1])
        
        break;
        case 21:this.makePig(message.Command[0],message.Command[1])
        
        break;
    default:console.log(GeZiManager.Tcharacter)
       console.log(message.Command[1]) 
    this.makeFH(message.Command[0],message.Command[1])
        break;
}



}if(message instanceof SHMessage&&message.SHtype=="TP"){
console.log(message.Content)
console.log(message.Command[0])
AnimalManager.TP(message.Content,message.Command[0])





}


        for(let mannger of this.YuanGong){
mannger.ReceiveMessage(message);


    }
}




}















}

